package com.cdut.logistics.action.system;

import java.util.Date;
import java.util.List;

import com.cdut.logistics.service.impl.system.CharacServiceImp;
import com.cdut.logistics.service.interf.system.CharacService;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.cdut.logistics.model.entity.system.Character;
import com.cdut.logistics.intercepter.system.AuthorityIntercepter;
import com.cdut.logistics.intercepter.system.LoginIntercepter;
/**
 * 
 * @ClassName: CharacterController  
 * @Description: TODO(角色管理的action)  
 * @author lxh
 * @date 2018年1月28日 下午2:26:50
 */
@Before(AuthorityIntercepter.class)
public class CharacterController extends Controller{
	private CharacService characServiceImp=new CharacServiceImp();

//	Id			
//	Name
//	Authority_id
//	is_use
//	Active
//	Created
//	Updated
	
	/**
	 * 
	 * @Title: addCharac  
	 * @Description: TODO(增加权限)
	 * @author lxh
	 * @throws
	 */
	public void addCharac(){
		String name=getPara("name");
		String authority_id=getPara("authority_id");
		String is_use="1";
		String active="1";
		Date created = new Date();
		boolean result=characServiceImp.addCharac(name, authority_id,is_use,active,created);
		setAttr("result",result);
		renderJson();
	}
	/**
	 * 
	 * 
	 * @Title: upDateCharac  
	 * @Description: TODO(修改角色)
	 * @author lxh
	 * @throws
	 */
	public void updateCharac(){
		String id=getPara("id");
		String name=getPara("name");
		String Authority_id=getPara("Authority_id");
		String is_use=getPara("is_use");
		Date updated=new Date();
		boolean result=characServiceImp.updateCharac(id,name, Authority_id, is_use,updated);
		setAttr("result",result);
		renderJson();
	}
	/**
	 * 
	 * 
	 * @Title: queryCharac  
	 * @Description: TODO(查询角色)
	 * @author lxh
	 * @throws
	 */
	public void queryCharacById(){
		String id=getPara("id");
		Character result=new Character();
		result=characServiceImp.queryCharacInfoById(id);
		setAttr("result",result);
		renderJson();
		
	}
	/**
	 * 
	 * @Title: queryAllCharac  
	 * @Description: TODO(查询所有角色信息)
	 * @author lxh
	 * @throws
	 */
	public void queryAllCharac(){
		List<Character> characterList=characServiceImp.queryAllCharac();
		characterList=characServiceImp.queryAllCharac();
		setAttr("characterList",characterList);
		renderJson();
	}
	public void queryCharacByName(){
		String name=getPara("name");
		Character result=new Character();
		result=characServiceImp.queryCharacInfoByName(name);
		setAttr("result",result);
		renderJson();
	}
	/**
	 * 
	 * 
	 * @Title: deleteCharac  
	 * @Description: TODO(逻辑删除角色，active 1->0)
	 * @author lxh
	 * @throws
	 */
	public void deleteCharac(){
		String id=getPara("id");
		boolean result=characServiceImp.deleteCharac(id);
		setAttr("result",result);
		renderJson();
	}
	/**
	 * 
	 * @Title: userRoleId  
	 * @Description: TODO(用户注册时调用生成普通用户的role_id)
	 * @author lxh
	 * @return
	 * @throws
	 */
	public int userRoleId(){
		int role_id=5;
		return role_id;
	}
	/**
	 * 
	 * @Title: adminRoleId  
	 * @Description: TODO(用户注册时调用生成管理员role_id)
	 * @author lxh
	 * @return
	 * @throws
	 */
	public int adminRoleId(){
		int role_id=1;
		return role_id;
	}
	/**
	 * 
	 * @Title: repairMemRoleId  
	 * @Description: TODO(用户注册时调用生成维修人员role_id)
	 * @author lxh
	 * @return
	 * @throws
	 */
	public int repairMemRoleId(){
		int role_id=4;
		return role_id;
	}
	/**
	 * 
	 * @Title: repairLeaderRoleId  
	 * @Description: TODO(用户注册时调用生成维修组长role_id)
	 * @author lxh
	 * @return
	 * @throws
	 */
	public int repairLeaderRoleId(){
		int role_id=3;
		return role_id;
	}
	/**
	 * 
	 * @Title: operationMemRoleId  
	 * @Description: TODO(用户注册时调用生成运维人员role_id)
	 * @author lxh
	 * @return
	 * @throws
	 */
	public int operationMemRoleId(){
		int role_id=2;
		return role_id;
	}

}
